package com.wang.mall.controller;

import com.wang.mall.model.LoginResult;
import com.wang.mall.model.R;
import com.wang.mall.service.UmsMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/member")
public class MemberController {

    @Autowired
    private UmsMemberService umsMemberService;

    @PostMapping("/login")
    public R login(@RequestBody Map<String, String> params) {
        String username = params.get("username");
        String password = params.get("password");
        LoginResult loginResult = umsMemberService.login(username, password);
        return R.ok(loginResult);
    }
}
